package com.you.bio.RandomAccessFile;

import com.you.bio.constant.Constants;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;

/**
 * 测试对文件的随机读写操作
 */
public class RandomAccessFileDemo {

    public static void main(String[] args) throws Exception {
        RandomAccessFile randomAccessFile = new RandomAccessFile(new File(Constants.INPUT_FILE_PATH), "rw");
        long offset = randomAccessFile.length();
        System.out.println(randomAccessFile.length());
        randomAccessFile.setLength(offset);
        randomAccessFile.seek(offset);
        randomAccessFile.write("这是追加的内容测试".getBytes("UTF-8"));
        System.out.println(randomAccessFile.length());
        Thread.sleep(10000L);
    }
}
